package rs.pnv.model.response;

import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.NotBlank;

import rs.pnv.model.AbstractEntity;

@Entity
@Table(name = "SEP_BANK_AUT")
@XmlAccessorType(XmlAccessType.FIELD)
public class BankAut extends AbstractEntity {

	@NotBlank
	@Column(nullable = false)
	@XmlElement(nillable = false)
	private BigInteger orderId;

	@OneToOne(optional = true)
	private PaymentResponse paymentResponse;

	@OneToOne(optional = true)
	private IssuerResponse issuerResponse;

	public BankAut() {

	}

	public BigInteger getOrderId() {
		return orderId;
	}

	public void setOrderId(BigInteger orderId) {
		this.orderId = orderId;
	}

	public PaymentResponse getPaymentResponse() {
		return paymentResponse;
	}

	public void setPaymentResponse(PaymentResponse paymentResponse) {
		this.paymentResponse = paymentResponse;
	}

	public IssuerResponse getIssuerResponse() {
		return issuerResponse;
	}

	public void setIssuerResponse(IssuerResponse issuerResponse) {
		this.issuerResponse = issuerResponse;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
				.append(orderId)
				.appendSuper(super.hashCode())
				.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}

		final BankAut otherBankAut = (BankAut) obj;

		return new EqualsBuilder()
				.append(orderId, otherBankAut.getOrderId())
				.appendSuper(super.equals(obj))
				.isEquals();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("orderId", orderId)
				.append(super.toString())
				.toString();
	}

}
